{% extends 'base.html' %}
{% load humanize %}
{% block page-content %}
{% include 'nav_cat_bar.html' %}

<div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-lg-10">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>修改权限信息</h5>
                        <div class="ibox-tools">
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                            <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                                <i class="fa fa-wrench"></i>
                            </a>
                            <ul class="dropdown-menu dropdown-user">
                                <li><a href="#">未启用 1</a>
                                </li>
                                <li><a href="#">未启用 2</a>
                                </li>
                            </ul>
                            <a class="close-link">
                                <i class="fa fa-times"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">
                        {% for dept in dept_info %}
                        <form method="post" id="deptForm" class="form-horizontal" action="">
                            {% if info %}
                                <div class="alert alert-success text-center">{{ info }}</div>
                            {% endif %}
                            <div class="form-group">
                                <label for="dept_name" class="col-sm-2 control-label">部门名称<span class="red-fonts">*</span></label>
                                <div class="col-sm-8">
                                    <input id="dept_name" name="dept_name" placeholder="部门名称" type="text" class="form-control" value="{{dept.name}}" >
                                    <input id="dept_id" name="dept_id" style="display:none;" type="text" class="form-control" value="{{dept.id}}" >
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label for="name" class="col-sm-2 control-label">备注<span class="red-fonts">*</span></label>
                                <div class="col-sm-8">
                                    <input id="dept_url" name="dept_comment" placeholder="备注" type="text" class="form-control" value="{{dept.comment}}" >
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <div class="col-sm-4 col-sm-offset-2">
                                <button id="submit_button"  class="btn btn-primary" type="submit">确认保存</button>
                                </div>
                            </div>
                        </form>
                        {% endfor %}
                    </div>
                </div>
            </div>
        </div>
    </div>

<script>
$('#deptForm').validator({
    timely: 2,
    theme: "yellow_right_effect",
    rules: {
        check_ip: [/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])(\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])){3}$/, 'ip地址不正确'],
        check_port: [/^\d{1,5}$/, '端口号不正确'],
        type_m: function(element){
                    return  $("#M").is(":checked");
            }
    },
        "dept_name": {
            rule: "required",
            tip: "部门名称",
            ok: "",
            msg: {required: "必须填写"}
        },
        "dept_url": {
            rule: "required",
            tip: "备注",
            ok: "",
            msg: {required: "必须填写"}
        },
    },
    valid: function(form) {
        form.submit();
    }
});

</script>







{% endblock %}
